<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-sclae=1.0,user-scalable=0">
	<title>xuluo</title>
	<script type="text/javascript" src="js/wfQuery.js"></script>
	<style type="text/css">
		*{margin:0;padding:0;-webkit-tap-highlight-color:transparent}html{font:12px 'Helvetica Neue','PingFang SC',STHeitiSC-Light,Helvetica,microsoft yahei,Arial;-webkit-text-size-adjust:100%}body{max-width:640px;margin:0 auto}li,ul{list-style:none}a{text-decoration:none;background:0 0;color:#666}a:active,a:hover{outline:0}.city{color:#666;font-size:15px}.city .title{background:#f0f9fe;color:#666;font-size:14px;padding:10px 0 10px 5%}.city table{width:90%;margin:10px auto;border-collapse:collapse;text-align:center}.city table td,.city table th{border:1px solid #ddecfa;padding:5px 0}.city table th{color:#555}.city p{font-size:14px;width:90%;margin:0 auto 10px auto;line-height:1.8}.city p span{font-size:13px}
	</style>
</head>
<body>
	<div class="city">
		<div class="title">目前支持的城市有：</div>
		<div id="list">
			
		</div>
	</div>
	<script>	
		var timestamp=new Date().getTime(); //时间戳 
		$.ajax({
		    url: "json/getOpenCity.json",
			type:"post",
			data:{timestamp:timestamp},
		    success: function(json){		        
		        var d=json.data;
		        console.log(json);
		        var txt="";
		        var provinceCode="";
		        for(var i=0;i<d.length;i++){
		        	if(provinceCode==""||provinceCode!=d[i].provinceCode){
		        		provinceCode=d[i].provinceCode;
		        		txt=txt+"<tr><td rowspan='"+getCount(d,d[i].provinceCode)+"'>"+d[i].provinceName+"</td><td>"+d[i].cityName+"</td></tr>";
		        	}else{
		        		txt=txt+"<tr><td>"+d[i].cityName+"</td></tr>";
		        	}
		        }
		        $('#list').append("<table><tr><th>省会</th><th>城市</th></tr>"+txt+"</table>");
		      	
		    },
		    error:function(xhr){
		    	console.log("失败："+xhr);
		    }
		});
		
		function getCount(data,provinceCode){
			var count=0;
			for(var i=0;i<data.length;i++){
				if(data[i].provinceCode==provinceCode){
					count++;
				}
			}
			return count;
		}
	</script>
</body>
</html>